package testing;

import sumoTween.Tweener;

public class TestSumoTween 
{

	public static void main(String[] args) 
	{
		TestSumoTween t=new TestSumoTween();

		System.out.println("set keyframe tests");
		t.setTest1();
		t.setTest2();
		t.setTest3();
		t.setTest4();
		t.setTest5();
		t.setTest6();
		t.setTest7();
		t.setTest8();

		System.out.println("add remove tests");
		t.arTest1();
		t.arTest2();
		t.arTest3();
	}

	public void arTest1()
	{
		Tweener t=new Tweener();
		t.set(0,1.0f);
		t.add(1, 0);
		boolean ok = t.getNumKeys() == 2;
		result("numkeys() test",ok);
	}

	public void arTest2()
	{
		Tweener t=new Tweener();
		t.set(0,1.0f);
		t.set(2.1f, 0.5f);

		//t.printKeys();

		t.deleteKeyAt(2.1f);

		//t.printKeys();

		boolean ok = t.getNumKeys() == 1;
		result("deletekey test",ok);
	}


	public void arTest3()
	{
		Tweener t=new Tweener();
		t.set(0,1.0f);
		t.set(2.1f, 0.5f);
		t.add(1.0f,1.0f);
		t.add(1.1f,1.0f);
		t.add(1.2f,1.0f);
		
		t.clear();

		boolean ok = t.getNumKeys() == 1;
		result("tweener clear test",ok);
	}

	
	
	public void setTest1()
	{
		Tweener t=new Tweener();
		t.set(0.75f);
		boolean ok=t.getValue()==0.75f;
		
		result("test1",ok);
	}

	public void setTest2()
	{
		Tweener t=new Tweener();
		t.set(0,0.2f);
		t.set(1,0.8f);
		boolean ok=t.getValue(0.5f)==0.5f;
		
		result("test2",ok);
	}

	public void setTest3()
	{
		Tweener t=new Tweener();
		t.set(0,0.0f);
		t.set(1,100.0f);
		boolean ok=t.getValue(0.5f)==50f;
		
		result("test3",ok);
	}
	
	public void setTest4()
	{
		Tweener t=new Tweener();
		t.set(1,0.0f);
		t.set(11,100.0f);
		boolean ok=t.getValue(6f)==50f;
		
		result("test4",ok);
	}
	
	public void setTest5()
	{
		Tweener t=new Tweener();
		t.set(0,0.0f);
		t.set(1,1.0f);
		t.set(2,1.0f);
		boolean ok=t.getValue(1.5f)==1f;
		
		result("get value in between 2 keys with same value",ok);
	}
	
	public void setTest6()
	{
		Tweener t=new Tweener();
		t.set(0,0.0f);
		t.set(1,1.0f);
		t.set(2,0.0f);
		boolean ok=t.getValue(1.5f)==0.5f;
		
		result("get value in between 2 keys",ok);
	}

	public void setTest7()
	{
		Tweener t=new Tweener();
		t.set(0,0.0f);
		t.set(1,1.0f);

		boolean ok=t.getValue(3f)==1.0f;
		
		result("get value after last keyframe",ok);
	}

	public void setTest8()
	{
		Tweener t=new Tweener();
		t.set(0,0.0f);
		t.set(1,1.0f);
		t.set(2,1.0f);
		boolean ok= t.getValue(2.f)==1f && t.getValue(1.f)==1f;
		
		result("test8",ok);
	}

	
	
	
	
	
	
	
	
	
	private void result(String s, boolean ok)
	{
		System.out.print("  "+s+" ");
		
		for(int i=s.length()+1;i<70;i++)
		{
			System.out.print(".");
		}
		
		System.out.print(" ");
		
		if(ok)
			System.out.println("ok");
		else
			System.out.println("ERROR");
	}
	
	
}
